#ifndef IOWIDGET_H
#define IOWIDGET_H

#include <QHeaderView>

#include "gainwidget.h"
#include "delaywidget.h"

#include "dynamicxwidget.h"
#include "freqgainucswidget.h"
#include "xoverwidget.h"
#include "eqopwidget.h"

#include "xx/typedef.h"

using PARAMIO = std::variant<PARAM_MUS, PARAM_OUT>;

class IOWidget : public AWidget
{
    Q_OBJECT
public:
    enum Type
    {
        Input,
        Output
    };
    Q_ENUM(Type)
    explicit IOWidget(const Type &type, const uint8_t &channel, const stDevCfg &cfg, const stDevLimt &limt, QWidget *parent = nullptr);
    Type type() const;
    uint8_t channel() const;
public slots:
    void set(const PARAMIO &param);
    void peak(const uint8_t &value);
signals:
    void compressor(uint8_t channel, const stDataCmps &value);
    void limiter(uint8_t channel, const stDataLimt &value);
    void noiseGate(uint8_t channel, const stDataNsgt &value);
    void xover(uint8_t channel, uint8_t type, const stDataXover &value);
    void peq(uint8_t channel, uint8_t index, const stDataEq &value);
protected slots:
    void xoverStateChanged(const Xover &xo, bool init);
    void eqStateChanged(const int &index, const EQ &eq, bool init);
    void dynamicXStateChanged(const DXVariant &dx);
    void ucsStateChanged(const int &index, const DMVariant &dm);
private:
    template <class T>
    void set(const T &param, int size);
private:
    const Type m_type;
    const uint8_t m_channel;
    QList<DMVariant> m_dmList;

    FreqGainUCSWidget *ucs;
    GainWidget *gain;
    DelayWidget *delay;
    XoverWidget *xoverWidget;
    EqOpWidget *eqOp;
    DynamicXWidget *dynamicX;
};

#endif // IOWIDGET_H
